package com.honglang.module.article.entity;

import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;


@Entity
@Table(name="blogArticle")
public class BlogArticle {

	/**
	 * @uml.property  name="id"
	 */
	private Integer id;

	/**
	 * @uml.property  name="viewsCount"
	 */
	private int viewsCount;

	/**
	 * @uml.property  name="commentsCount"
	 */
	private int commentsCount;

	/** 
	 * @uml.property name="article"
	 * @uml.associationEnd multiplicity="(1 1)" aggregation="shared" inverse="blogArticle2:com.honglang.entity.Article"
	 */
	private Article article ;
	
	
	
	private boolean displayReadMore;
	
	
	private boolean CommentOpen;
	
	
	/** 
	 * @uml.property name="comment"
	 * @uml.associationEnd multiplicity="(0 -1)" aggregation="shared" inverse="blogArticle:com.honglang.entity.Comment"
	 */
	
	private transient Collection<BlogArticleComment> comment;
	
	
	
	
	/**
	 * Getter of the property <tt>viewsCount</tt>
	 * @return  Returns the viewsCount.
	 * @uml.property  name="viewsCount"
	 */
	@Column
	public int getViewsCount() {
		return viewsCount;
	}

	/**
	 * Setter of the property <tt>viewsCount</tt>
	 * @param viewsCount  The viewsCount to set.
	 * @uml.property  name="viewsCount"
	 */
	public void setViewsCount(int viewsCount) {
		this.viewsCount = viewsCount;
	}

	/**
	 * Getter of the property <tt>commentsCount</tt>
	 * @return  Returns the commentsCount.
	 * @uml.property  name="commentsCount"
	 */
	@Column
	public int getCommentsCount() {
		return commentsCount;
	}

	/**
	 * Setter of the property <tt>commentsCount</tt>
	 * @param commentsCount  The commentsCount to set.
	 * @uml.property  name="commentsCount"
	 */
	public void setCommentsCount(int commentsCount) {
		this.commentsCount = commentsCount;
	}

	/** 
	 * Getter of the property <tt>article</tt>
	 * @return  Returns the article.
	 * @uml.property  name="article"
	 */
	@OneToOne(fetch=FetchType.EAGER,cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE})
	@JoinColumn
	public Article getArticle() {
		return article;
	}

	/** 
	 * Setter of the property <tt>article</tt>
	 * @param article  The article to set.
	 * @uml.property  name="article"
	 */
	public void setArticle(Article article) {
		this.article = article;
	}

	/** 
	 * Getter of the property <tt>comment</tt>
	 * @return  Returns the comment.
	 * @uml.property  name="comment"
	 */
	@OneToMany(fetch=FetchType.LAZY,mappedBy="blogArticle")
	public Collection<BlogArticleComment> getComment() {
		return comment;
	}

	/** 
	 * Setter of the property <tt>comment</tt>
	 * @param comment  The comment to set.
	 * @uml.property  name="comment"
	 */
	public void setComment(Collection<BlogArticleComment> comment) {
		this.comment = comment;
	}

	/**
	 * Getter of the property <tt>id</tt>
	 * @return  Returns the id.
	 * @uml.property  name="id"
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	/**
	 * Setter of the property <tt>id</tt>
	 * @param id  The id to set.
	 * @uml.property  name="id"
	 */
	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column
	public boolean isDisplayReadMore() {
		return displayReadMore;
	}

	public void setDisplayReadMore(boolean displayReadMore) {
		this.displayReadMore = displayReadMore;
	}
	
	
	@Column
	public boolean isCommentOpen() {
		return CommentOpen;
	}

	public void setCommentOpen(boolean commentOpen) {
		CommentOpen = commentOpen;
	}
	
	
	
	
	
}
